home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / sjpegd.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.7 KB  |  90 lines

  1. /* Copyright (C) 1994, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: sjpegd.c,v 1.2 2000/09/19 19:00:50 lpd Exp $ */
  20. /* Interface routines for IJG decoding code. */
  21. #include "stdio_.h"
  22. #include "string_.h"
  23. #include "jpeglib_.h"
  24. #include "jerror_.h"
  25. #include "gx.h"
  26. #include "gserrors.h"
  27. #include "strimpl.h"
  28. #include "sdct.h"
  29. #include "sjpeg.h"
  30.  
  31. /*
  32.  * Interface routines.  This layer of routines exists solely to limit
  33.  * side-effects from using setjmp.
  34.  */
  35.  
  36. int
  37. gs_jpeg_create_decompress(stream_DCT_state * st)
  38. {                /* Initialize error handling */
  39.     gs_jpeg_error_setup(st);
  40.     /* Establish the setjmp return context for gs_jpeg_error_exit to use. */
  41.     if (setjmp(st->data.common->exit_jmpbuf))
  42.     return_error(gs_jpeg_log_error(st));
  43.  
  44.     jpeg_create_decompress(&st->data.decompress->dinfo);
  45.     jpeg_stream_data_common_init(st->data.decompress);
  46.     return 0;
  47. }
  48.  
  49. int
  50. gs_jpeg_read_header(stream_DCT_state * st,
  51.             boolean require_image)
  52. {
  53.     if (setjmp(st->data.common->exit_jmpbuf))
  54.     return_error(gs_jpeg_log_error(st));
  55.     return jpeg_read_header(&st->data.decompress->dinfo, require_image);
  56. }
  57.  
  58. int
  59. gs_jpeg_start_decompress(stream_DCT_state * st)
  60. {
  61.     if (setjmp(st->data.common->exit_jmpbuf))
  62.     return_error(gs_jpeg_log_error(st));
  63. #if JPEG_LIB_VERSION > 55
  64.     return (int)jpeg_start_decompress(&st->data.decompress->dinfo);
  65. #else
  66.     /* in IJG version 5, jpeg_start_decompress had no return value */
  67.     jpeg_start_decompress(&st->data.decompress->dinfo);
  68.     return 1;
  69. #endif
  70. }
  71.  
  72. int
  73. gs_jpeg_read_scanlines(stream_DCT_state * st,
  74.                JSAMPARRAY scanlines,
  75.                int max_lines)
  76. {
  77.     if (setjmp(st->data.common->exit_jmpbuf))
  78.     return_error(gs_jpeg_log_error(st));
  79.     return (int)jpeg_read_scanlines(&st->data.decompress->dinfo,
  80.                     scanlines, (JDIMENSION) max_lines);
  81. }
  82.  
  83. int
  84. gs_jpeg_finish_decompress(stream_DCT_state * st)
  85. {
  86.     if (setjmp(st->data.common->exit_jmpbuf))
  87.     return_error(gs_jpeg_log_error(st));
  88.     return (int)jpeg_finish_decompress(&st->data.decompress->dinfo);
  89. }
  90.